Skip to content

feat(pm-console): report a unit that keeps failing on its timer, once, and its mending - #12719

Merged
dezren39 merged 2 commits into
mainfrom
claude/pm-unit-trouble
Nov 23, 2026
Merged

dezren39 merged 2 commits into
mainfrom
claude/pm-unit-trouble

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Why

On 2026-11-22 pm-git-sync failed every 30 seconds for two hours, the laptop deployed nothing that was merged, and the only record was the journal (#12520, second part).

pm-git-sync.service and its timer are in the console's unit list (pm-*), so the notifier could see it. What it did with a unit on a timer was wrong both ways: it reported the first failed run it happened to see, which is noise when the next run mends it, and after that said nothing for as long as the unit went on being caught between "failed" and "starting".

What changes

  • A service with a timer of the same name counts as running on a timer.
  • Such a unit is reported once it has been failing run after run for five minutes: "A unit keeps failing", with the unit's own description of what it is for. Being caught in the middle of a run is neither a failure nor a recovery.
  • When it is seen well again, that is said once too.
  • A service that stays up is reported the moment it is seen failed, as before, and its recovery is not news.
  • A state kept from before this change does not re-report what was already reported.

Checks

  • bun test: 144 pass. The new test walks one bad run, a mended run, sustained failure through mid-run sightings, the single report, the single recovery, a second episode, services without a timer, a timer with another name, an older kept state, a unit that leaves the list, and a pass where the services could not be read.
  • Six planted faults (one bad run reported, mid-run counted as recovery, never says it mended, any timer makes it periodic, old state told again, unlisted units linger) are each caught.

Not checked

  • On the laptop itself: the session's access to it was used up, so this was not watched against the real unit. The states used in the test are the ones systemctl --user list-units gives for a oneshot on a timer.

Refs #12520.


Generated by Claude Code


See it in action
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…, and its mending

On 2026-11-22 pm-git-sync failed every 30 seconds for two hours and the
only record was the journal. The notifier reported a failed unit the
first time it saw one, which for a unit on a timer is either noise (one
bad run the next run mends) or, once it had been seen, silence for as
long as it went on being caught between "failed" and "starting".

A service with a timer of the same name is now reported once it has
failed run after run for five minutes, with what the unit is for, and
again when it is seen well. Being caught mid-run is neither. Services
that stay up are reported at once, as before.

Six planted faults in the new logic are each caught.

Refs #12520.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF
@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 23:57
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c8c5b222-e237-44a6-9b5d-608442b06b5b
Commits

Reviewing files that changed from the base of the PR and between 56ad4c4 and e56b402.

Files selected for processing: 6

  • pm-stack/console/README.md
  • pm-stack/console/edge/src/edge.ts
  • pm-stack/console/src/docs.ts
  • pm-stack/console/src/notify.ts
  • pm-stack/console/test/edge.test.ts
  • pm-stack/console/test/push.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T00:05:36.568905Z e56b402 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0521a095f9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +121 to +122
const sustained = at - entry.since >= SUSTAINED_MS;
if (!entry.told && (!onTimer(u.unit) || sustained)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reevaluate pending failures on unchanged host reports

On the edge, a timer service that consistently reports failed can remain unreported indefinitely. EdgeLink.once() sends section payloads only when their hashes change (src/sync.ts), and the edge sync handler invokes notifier.tick() only when a watched payload changes (edge/src/edge.ts:665–666). Consequently, the first failed snapshot starts this five-minute window, but subsequent identical snapshots never reevaluate it unless another watched section changes or a user action triggers the notifier. The edge has no periodic notifier loop, and its alarm only handles host silence. Reevaluate pending episodes on fresh host confirmations even when their content is unchanged.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real: a unit that stays failed reads the same in every report, so at the edge the five minutes never elapsed. Fixed in the next commit: while a unit's failing is being timed (Notifier.pending()), the edge runs the notifier on every report, changed or not. New edge test: the unit goes failed, eleven identical reports follow, nothing is sent at four and a half minutes, one message after five, none after that, and one more when it mends. Reverting the condition fails that test.


Generated by Claude Code

Comment thread pm-stack/console/src/notify.ts Outdated
await this.docs.touch(WATCHED.filter((n) => !skip.includes(n)));
const now = Object.fromEntries(WATCHED.map((n) => [n, this.docs.good(n)])) as State;
const { messages, seen } = changes(await this.load(), now);
const { messages, seen } = changes(await this.load(), now, this.now());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check service freshness before advancing failure duration

If one timer failure is observed and subsequent service reads fail, the local notifier can still announce sustained failure five minutes later without another successful observation. Docs.refresh() retains the previous data on errors, and Docs.good("services") returns that cached snapshot, so this call repeatedly evaluates the original failure against the current wall clock. The new services: null test does not exercise this production path because failed refreshes do not return null after an initial successful read. Carry service-read health and timestamps into the comparison so stale snapshots cannot establish sustained failure.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real, and the services: null test did not reach it, as you say. Fixed in the next commit: the time is no longer the clock but when the unit list was last actually read (Docs.goodAt), so a list that has stopped being read cannot age a failure. And after a gap longer than the wait itself the count starts again from the next sighting, since nothing is known of what the unit did in between. New test at the Notifier level with the real Docs: one failed run is seen, the list is unreadable for half an hour (nothing sent), reads resume and it is reported after five observed minutes. Planted faults for clock-based time, for counting across a gap, and for ignoring a mid-run sighting are each caught.


Generated by Claude Code

…unting at the edge

Two review findings on the sustained-failure report:

- At the edge the notifier only ran when a watched section changed, and
  a unit that stays failed reads the same in every report, so the five
  minutes never elapsed. While a unit's failing is being timed, the
  edge now looks again on every report.
- On the laptop, a list of units that could no longer be read kept its
  last copy, and the old failure in it was timed against the clock. How
  long a unit has been failing is now counted between readings, from
  the time the list was last actually read; and after a gap longer than
  the wait itself the count starts again, since nothing is known of
  what happened in between.

Four planted faults in these fixes are each caught.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF
@dezren39
dezren39 merged commit 7e3c3bd into main Nov 23, 2026
1 check passed
@dezren39
dezren39 deleted the claude/pm-unit-trouble branch November 23, 2026 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants